/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.iti.jets.gpts.service;

import com.iti.jets.gpts.dto.assist.Business;
import com.iti.jets.gpts.pojo.Point;
import java.util.ArrayList;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.codehaus.jettison.json.JSONObject;

/**
 *
 * @author mustafajnr
 */

@Path("/get-point")
public class PointRetrievalService {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getPoint(
            @QueryParam("point") String point
    ) {
        Point p = Business.getPoint(point);
        if (p != null) 
        {
            try
            {
            JSONObject jSONObject = new JSONObject();
           
            jSONObject.put("id",p.getId());
            jSONObject.put("Loc", p.getLocation());
            jSONObject.put("name", p.getName());
            jSONObject.put("stop", p.getIsStop());
            return jSONObject.toString();
            }
            catch(Exception e)
            {
                e.printStackTrace();
                return "Error";
            }
            
        }
        return "-1";
    }
}
